
import { UIID } from "../ui/UIConst";
import { UIManager } from "../ui/UIManager";

const {ccclass, property,requireComponent} = cc._decorator;

@ccclass
@requireComponent(cc.Button)
export default class OpenUIBtn extends cc.Component {

    @property({ type: cc.Enum(UIID)})
    protected id: UIID = UIID.Dialog;

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        let handler = new cc.Component.EventHandler();
        handler.target = this.node;
        handler.component = 'OpenUIBtn';
        handler.handler = 'onClick';
        this.node.getComponent(cc.Button).target = this.node;
        this.node.getComponent(cc.Button).clickEvents = [handler];
    }

    onClick(){
        UIManager.instance.open(this.id);
    }

    // update (dt) {}
}
